package thread;

import java.util.concurrent.Semaphore;

public class Demo17_Semaphore {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(4);
        System.out.println(semaphore);
        while(true){
            semaphore.acquire();
            System.out.println("P");
            System.out.println("available:"+ semaphore.availablePermits());
        }
    }
}
